package com.kamistoat.meimeimall.meimeimallcoupon.service.impl;

import com.kamistoat.meimeimall.common.annotation.WithCache;
import com.kamistoat.meimeimall.common.constant.DatabaseConstant;
import com.kamistoat.meimeimall.meimeimallcoupon.dao.SpuBoundsDao;
import com.kamistoat.meimeimall.meimeimallcoupon.entity.SpuBoundsEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.kamistoat.meimeimall.meimeimallcoupon.service.SpuBoundsService;


@Service("spuBoundsService")
public class SpuBoundsServiceImpl implements SpuBoundsService {
    protected Logger logger = LoggerFactory.getLogger(SpuBoundsServiceImpl.class);

    @Autowired
    SpuBoundsDao spuBoundsDao;

    /**
     * 带缓查询指定spuId对应的积分
     *
     * @param spuId
     */
    @Override
    @WithCache(prefix = "coupon:spu:coupon:#spuId", isList = false, returnType = SpuBoundsEntity.class)
    public SpuBoundsEntity getBoundBySpuId(Long spuId) {
        SpuBoundsEntity wrapper = new SpuBoundsEntity();
        wrapper.setSpuId(spuId);
        wrapper.setDelete(DatabaseConstant.UN_LOGISTIC_DELETED);
        List<SpuBoundsEntity> selectRes = spuBoundsDao.selectByWrapper(wrapper);
        return selectRes.get(0);
    }

}